<?php

/**
 * @filename Common.php 
 * @encoding UTF-8 
 * @author yuzhiyuan <307090870@qq.com>
 * @copyright copyright 2013 (c) Emagsoftware Technology Co., Ltd. All Rights reserved.
 * @license ……
 * @datetime 2013-6-22  13:01:24
 * @version 1.0
 * @Description
  */


function p($obj){
    echo '<pre>';
    print_r($obj);
    echo '</pre>';
    
}

//根据分类ID查找父类ID或者名称  $type为0时，找名称，1时找ID
function getCatePar($id=0,$type=0){
    $model = M('Cate');
    $p_id = $model->where("id = ".$id)->getField('p_id');
    $res = $model->where("id = ".$p_id)->find();
    if($type == 0){
        return $res['c_name'];
    }else{
        return $res['id'];
    }
}

/*
*  处理 [!_more_!] 标签  $type=0 时只替换，1时增加$suf后缀
*/
function subPost($str,$type = 0,$suf = '&nbsp;...'){
  //  return substr($str, 0, strpos($str,'_ueditor_page_break_tag_') );
    $res = explode('[!_more_!]', $str);
    if($type == 0){
        $res = $res[0];
    }else{
        $res = $res[0] . $suf;
    }
    return $res;
}

function rePost($str){
    return str_replace('[!_more_!]', '', $str);
}